import DebugExt from "../NRLib/base/DebugExt";

const { ccclass, property, menu } = cc._decorator;

/**
 * 常驻节点
 * 监听 ZEGO 一些事件
 */
@ccclass
@menu("ZEGO/ZegoComp")
export default class ZegoComp extends cc.Component {



    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        if (!cc.game.isPersistRootNode(this.node))
            cc.game.addPersistRootNode(this.node);
    }

    start() {
        // 游戏内侦听事件
        yy.event.on(this, yy.event.lobby.CommonEvent, (e: yy.event.lobby.CommonEvent) => {
            if (e.type == "OnCustomComponentChanged") {
                // 外部控制控件是否显示
                let com: yy.ICustomComponent = e.data;
                DebugExt.log("OnCustomComponentChanged: ", e);
            } else if (e.type == "GetCustomComponent") {
                // 预设游戏内可由上层APP控制的控件
                let list: yy.ICustomComponent[];
                e.data = list;
                DebugExt.log("GetCustomComponent: ", e);
            }
        })
    }

}
